﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CSharpHW
{
    public partial class Accounting : Form
    {

        private static String InOutCome = "支出";
        private static int Year = 2016;
        private static int Month = 1;
        private static int Day = 1;
        private static Timer timer1;
        private static String Amount = "";
        private static String ExtraText = "";
        private static String Catagory = "";
        private static int CataNum = 0;
        public Accounting()
        {
            InitializeComponent();
        }

        private void button4_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button7_Click(object sender, EventArgs e)
        {

            NormalBtn_Out.Visible = true;
            DietBtn_Out.Visible = true;
            TrafficBtn_Out.Visible = true;
            ClothesBtn_Out.Visible = true;
            MedicalBtn_Out.Visible = true;
            CommunicationBtn_Out.Visible = true;
            MakeupBtn_Out.Visible = true;
            StudyBtn_Out.Visible = true;
            ChemicalBtn_Out.Visible = true;
            EntertainmentBtn_Out.Visible = true;
            SocialBtn_Out.Visible = true;
            OtherBtn_Out.Visible = true;//显示类别中的支出项按钮

            NormalBtn_In.Visible = false;
            LivingExpenseBtn_In.Visible = false;
            BounsBtn_In.Visible = false;
            SalaryBtn_In.Visible = false;
            RedPacketBtn_In.Visible = false;
            OtherBtn_In.Visible = false;//隐藏类别中的收入项按钮


            InOutCome = "支出";
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void button9_Click(object sender, EventArgs e)
        {
            Catagory = "饮食";
            CataNum = 2;
        }

        private void IncomeBtn_Click(object sender, EventArgs e)
        {
            NormalBtn_Out.Visible             = false;
            DietBtn_Out.Visible               = false;
            TrafficBtn_Out.Visible            = false;
            ClothesBtn_Out.Visible            = false;
            MedicalBtn_Out.Visible            = false;
            CommunicationBtn_Out.Visible      = false;
            MakeupBtn_Out.Visible             = false;
            StudyBtn_Out.Visible              = false;
            ChemicalBtn_Out.Visible           = false;
            EntertainmentBtn_Out.Visible      = false;
            SocialBtn_Out.Visible             = false;
            OtherBtn_Out.Visible              = false;//隐藏类别中的支出项按钮

            NormalBtn_In.Visible              = true;
            LivingExpenseBtn_In.Visible       = true;
            BounsBtn_In.Visible               = true;
            SalaryBtn_In.Visible              = true;
            RedPacketBtn_In.Visible           = true;
            OtherBtn_In.Visible               = true;//显示类别中的收入项按钮


            InOutCome = "收入";
        }

        private void MedicalBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "医疗";
            CataNum = 5;
        }
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            timer1 = new Timer();
            LabelSave.Text = "Saved";
            timer1.Interval = 1000;
            timer1.Start();//在窗口中显示“saved"

            Year = int.Parse(ChooseYear.SelectedItem.ToString());
            Month = int.Parse(ChooseMonth.SelectedItem.ToString());
            Day = int.Parse(ChooseDay.SelectedItem.ToString());
            Amount = AmountNum.Text;
            ExtraText = RemarkText.Text;
            DBUtility db = new DBUtility();
            db.connect("1234", "root");
            DBUtility.insertIntoAccount(Catagory,CataNum,InOutCome,Year,Month,Day,Amount,ExtraText);
        }

        private void Accounting_Load(object sender, EventArgs e)
        {

        }

        private void RemarkText_TextChanged(object sender, EventArgs e)
        {
        }
        private void AccountStatamentBtn_Click(object sender, EventArgs e)
        {
            AccoutStatament account = new AccoutStatament();
            account.Show();
        }

        private void ClothesBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "服饰";
            CataNum = 4;
        }

        private void NormalBtn_In_Click(object sender, EventArgs e)
        {
            Catagory = "一般";
            CataNum = 13;
        }

        private void NormalBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "一般";
            CataNum = 1;
        }

        private void LivingExpenseBtn_In_Click(object sender, EventArgs e)
        {
            Catagory = "生活";
            CataNum = 14;
        }

        private void BounsBtn_In_Click(object sender, EventArgs e)
        {
            Catagory = "奖金";
            CataNum = 15;
        }

        private void TrafficBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "交通";
            CataNum = 3;
        }

        private void SalaryBtn_In_Click(object sender, EventArgs e)
        {
            Catagory = "工资";
            CataNum = 15;
        }

        private void RedPacketBtn_In_Click(object sender, EventArgs e)
        {
            Catagory = "红包";
            CataNum = 16;
        }

        private void OtherBtn_In_Click(object sender, EventArgs e)
        {
            Catagory = "其他";
            CataNum = 17;
        }

        private void CommunicationBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "通讯";
            CataNum = 6;
        }

        private void MakeupBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "化妆";
            CataNum = 7;
        }

        private void StudyBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "学习";
            CataNum = 8;
        }

        private void ChemicalBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "日化";
            CataNum = 9;
        }

        private void EntertainmentBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "娱乐";
            CataNum = 10;
        }

        private void SocialBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "社交";
            CataNum = 11;
        }

        private void OtherBtn_Out_Click(object sender, EventArgs e)
        {
            Catagory = "其他";
            CataNum = 12;
        }
    }
}
